<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<div class="block medium left">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        <h2>Details of land "<bean:write name="land" property="landID"/>"</h2>
    </div>
    <!-- .block_head ends -->
    
    <div class="block_content clearfix">
        <html:form styleId="landForm" action="admin/land.do" method="post">
            
            <logic:notEmpty name="errorMessages" >
                <div class="message errormsg">
                    <logic:iterate id="message" name="errorMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <logic:notEmpty name="successMessages" >
                <div class="message success">
                    <logic:iterate id="message" name="successMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <p>
                <html:hidden property="action" value="UpdateStatus"/>
                <label>Status: </label>
                <span class="text"><bean:write name="land" property="statusName"/>.&nbsp;&nbsp;&nbsp;
                    <logic:equal name="land" property="statusCode" value="CR">
                        <html:hidden property="statusCode" value="AB"/>
                        Update status: <html:submit value="Applied Building Permit" styleClass="submit longer"/>
                    </logic:equal>
                    <logic:equal name="land" property="statusCode" value="AB">
                        <html:hidden property="statusCode" value="RB"/>
                        <html:hidden property="permitType" value="building"/>
                        Update status: <html:submit value="Received Building Permit" styleClass="submit longer"/>
                    </logic:equal>
                    <logic:equal name="land" property="statusCode" value="RB">
                        <html:hidden property="statusCode" value="CS"/>
                        Update status: <html:submit value="Constructed" styleClass="submit mid"/>
                    </logic:equal>
                    <logic:equal name="land" property="statusCode" value="CS">
                        <html:hidden property="statusCode" value="AO"/>
                        Update status: <html:submit value="Applied Occupancy Permit" styleClass="submit longer"/>
                    </logic:equal>
                    <logic:equal name="land" property="statusCode" value="AO">
                        <html:hidden property="statusCode" value="RO"/>
                        <html:hidden property="permitType" value="occupancy"/>
                        Update status: <html:submit value="Received Occupancy Permit" styleClass="submit longer"/>
                    </logic:equal>
                    <logic:equal name="land" property="statusCode" value="RO">
                        <html:hidden property="statusCode" value="BS"/>
                        Update status: <html:submit value="To Be Sold" styleClass="submit mid"/>
                    </logic:equal>
                    <logic:equal name="land" property="statusCode" value="BS">
                        <html:hidden property="statusCode" value="S"/>
                        Update status: <html:submit value="Sold" styleClass="submit"/>
                    </logic:equal>
                </span>
            </p>
            <p>
                <label>Last Status Changed On: </label><span class="text"><fmt:formatDate type="both" value="${land.statusChangedDate}"/></span>                
            </p>
            <hr/>
            <p>
                <html:hidden property="landID" />
                <label>ID: </label>
                <span class="text"><bean:write name="land" property="landID"/></span>
            </p>
            <p>
                <label>Address: </label>
                <span class="text"><bean:write name="land" property="address"/></span>
            </p>
            <p>
                <label>Location: </label>
                <span class="text"><bean:write name="land" property="locationName"/></span>
            </p>
            <p>
                <label>Plan Laid: </label>
                <span class="text"><bean:write name="land" property="planName"/></span>
            </p>
            <p>
                <label>Area: </label>
                <span class="text"><bean:write name="land" property="landArea"/>
                &nbsp;sq.foot</span>
            </p>
            <p>
                <label>Near by (Landmarks): </label>
                <span class="text"><bean:write name="land" property="nearByLandMarks"/></span>
            </p>
            <p>
                <label>Purchased Cost: </label>
                <span class="text"><fmt:formatNumber value="${land.purchasedCost}"/>
                &nbsp;U.S. dollars</span>
            </p>
            <p>
                <label>Purchased On: </label>
                <span class="text"><fmt:formatDate type="date" value="${land.purchasedDate}"/></span>
            </p>
            <p>
                <label>Present Cost: </label>
                <span class="text"><fmt:formatNumber value="${land.presentCost}"/>
                &nbsp;U.S. dollars</span>
            </p>
        </html:form>
        
        <hr/>
        
        <html:form styleId="landForm" action="admin/land.do" method="post">
            <p>
                <html:hidden property="landID" />
                <html:submit property="action" value="Edit" styleClass="submit"/>
                <html:link styleClass="confirm-button submit small red" action="/admin/landListing.do?action=delete" paramId="landID" paramName="landForm" paramProperty="landID">
                    Delete
                </html:link>
                <html:link action="/admin/landListing.do" styleClass="submit long gray">Back to the list</html:link>
            </p>
        </html:form>
        
        
    </div>
    <!-- .block_content ends -->
    
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block.medium.left ends -->


<div class="block tiny right">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        
        <h2>Status History</h2>
    </div>
    <!-- .block_head ends -->

    
    <div class="block_content clearfix">
        
        <table cellpadding="0" cellspacing="0" width="100%" class="sortable">
            <thead>
                <th>Status</th>
                <th>Changed On</th>
            </thead>
            <tbody>
                <logic:iterate id="status" name="statusHistory">
                    <tr>
                        <td><bean:write name="status" property="statusName"/></td>
                        <td><fmt:formatDate type="both" value="${status.changedDate}"/></td>
                    </tr>
                </logic:iterate>
            </tbody>
            
        </table>
        
    </div>
    <!-- .block_content ends -->
    
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block.tiny.right ends -->


<div class="block">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        
        <h2>Land Cost History</h2>
    </div>
    <!-- .block_head ends -->
    
    <div class="block_content clearfix">
        
        
        <logic:present name="costHistory">
            <p class="chart_note">Cost of the Land = Area * Land Cost at the location of the land</p>
            <html:form styleClass="chart_form" action="/admin/land.do" method="get">
                <html:hidden property="landID" />
                
                <div class="chart_mode_wrapper clearfix">
                    <div class="content">
                        <a class="item submit table_mode gray">Table</a>
                        <a class="item submit chart_mode ">Chart</a>
                        <logic:notEmpty name="yearList">
                            <span class="item">
                                <label>Year:</label>
                                <html:select styleClass="chzn-select chart_year" property="year">
                                    <logic:iterate id="year" name="yearList">
                                        <html:option value="${year}">${year}</html:option>
                                    </logic:iterate>
                                </html:select>
                            </span>
                        </logic:notEmpty>
                    </div>
                </div>
            </html:form>
            <div class="clear"></div>
            <table class="stats" rel="line" cellpadding="0" cellspacing="0" width="100%">
                <caption>Land Cost in Year ${selectYear}</caption>
                <thead>
                    <tr>
                        <td>&nbsp;</td>
                        <logic:iterate id="cost" name="costHistory">
                            <th scope="col">${cost[0]}</th>
                        </logic:iterate>
                    </tr>
                </thead>
                
                <tbody>
                    <tr>
                        <th scope="row">Cost</th>
                        <logic:iterate id="cost" name="costHistory">
                            <td>${cost[1]*land.landArea}</td>
                        </logic:iterate>
                    </tr>
                </tbody>
            </table>
        </div>
        <!-- .block_content ends -->
        </logic:present>
    
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block ends -->

<div class="block">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        
        <h2>Permits</h2>
    </div>
    <!-- .block_head ends -->

    
    <div class="block_content clearfix">
        
        <logic:present name="havePermit">
            <logic:present name="buildingPermit">
                <h2>Building Permit</h2>
                <html:form action="admin/land.do">
                    <div>
                        <p>
                            <label>Issuer Name: </label>
                            <span class="text">
                                ${buildingPermit.issuerName}
                            </span>
                        </p>
                        <p>
                            <label>Issued Date</label>
                            <span class="text">
                                <fmt:formatDate type="date" value="${buildingPermit.issuedDate}"/>
                            </span>
                        </p>
                        <p>
                            <label>Signer Name: </label>
                            <span class="text">
                                ${buildingPermit.signerName}
                            </span>
                        </p>
                        <p>
                            <label>Description: </label>
                        </p>
                        ${buildingPermit.description}
                        <html:hidden property="landID" />
                        <html:hidden property="action" value="editBP"/>
                        <html:hidden property="permitType" value="building"/>
                        <p> <html:submit value="Edit" styleClass="submit small"/></p>
                    </div>
                </html:form>
            </logic:present>
            <logic:present name="occupancyPermit">
                <hr/>
                <h2>Occupancy Permit</h2>
                <html:form action="admin/land.do">
                    <div>
                        <p>
                            <label>Issuer Name: </label>
                            <span class="text">
                                ${occupancyPermit.issuerName}
                            </span>
                        </p>
                        <p>
                            <label>Issued Date</label>
                            <span class="text">
                                <fmt:formatDate type="date" value="${occupancyPermit.issuedDate}"/>
                            </span>
                        </p>
                        <p>
                            <label>Signer Name: </label>
                            <span class="text">
                                ${occupancyPermit.signerName}
                            </span>
                        </p>
                        <p>
                            <label>Description: </label>
                        </p>
                        ${occupancyPermit.description}
                        <html:hidden property="landID" />
                        <html:hidden property="action" value="editOP"/>
                        <html:hidden property="permitType" value="occupancy"/>
                        <p> <html:submit value="Edit" styleClass="submit small"/></p>
                    </div>
                </html:form>
            </logic:present>
        </logic:present>
        <logic:notPresent name="havePermit">
            <p class="align-center">There are no permits.</p>
        </logic:notPresent>
        
    </div>
    <!-- .block_content ends -->
    
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block ends -->